<?php defined('_JEXEC') or die('Restricted access'); ?>
<form action="index.php" method="post" name="adminForm">
<div id="editcell">
	<table class="adminlist">
	<tr>
		<td align="left" width="50%">
			Поиск: <input name="search" size="50" type="text" value="<?php if(isset($_POST[search])) echo $_POST[search];?>"/>
		</td>
		
		<td align="right" width="50%">
                        Есть на складе
                        <input type="checkbox" name="yes_sklad" value="1" <?=(isset($_REQUEST['yes_sklad'])?'checked':'');?> onchange="submitform();" />&nbsp;&nbsp;|&nbsp;
                        Нет на складе
                        <input type="checkbox" name="non_sklad" value="1" <?=(isset($_REQUEST['non_sklad'])?'checked':'');?> onchange="submitform();" />&nbsp;&nbsp;|&nbsp;
                        Не опубликованные
                        <input type="checkbox" name="non_published" value="1" <?=(isset($_REQUEST['non_published'])?'checked':'');?> onchange="submitform();" />&nbsp;&nbsp;|&nbsp;
			Категория: 
			<select id="cat_id" name="cat_id" onchange="submitform();">
				<option value=''>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</option>
				<?php foreach($this->categories as $category):?>
				<option value='<?php echo $category->id?>' <?php if(isset($this->cat_id) && $this->cat_id == $category->id) echo 'SELECTED';?>><?php echo $category->name?></option>
				<?php endforeach;?>
			</select>
		</td>
	</tr>
	</table>
	<table class="adminlist">
	
	<thead>
		<tr>
			<th width="5">
				<?php echo JText::_( 'ID' ); ?>
			</th>
			<th width="20">
				<input type="checkbox" name="toggle" value="" onclick="checkAll(<?php echo count( $this->items ); ?>);" />
			</th>	
			<th width="200">
				
			</th>			
			<th width="">
				<?php echo JText::_( 'Артикул' ); ?>
			</th>		
								
			<th width="">
				<?php echo JText::_( 'Название' ); ?>
			</th>
			
			<th width="">
				<?php echo JText::_( 'Категория' ); ?>
			</th>
			<th width="100px">
				<?php echo JText::_( 'Опубликовано' ); ?>
			</th>
			
		</tr>
	</thead>
	<tfoot>
		<tr>
			<td colspan="6">
			<div class="pagination">			
				<div class="button2-right off">
					<div class="start">
					<?php if($this->page != 1 ):?><a onclick="javascript: document.adminForm.page.value=1; submitform();return false;" title="Следующая" href="#">Начало</a>
						<?php else:?>
						<span>Начало</span>
						<?php endif;?>
					
					</div>
				</div>
				<div class="button2-right off">
					<div class="prev">
					<?php if($this->page > 2 ):?><a onclick="javascript: document.adminForm.page.value=<?php echo $this->page-1;?>; submitform();return false;" title="Следующая" href="#">Предыдущая</a>
						<?php else:?>
						<span>Предыдущая</span>
						<?php endif;?>
					
					</div>
				</div>
				<div class="button2-left">
				
					<div class="page">
					<?php for($i=1;$i<=$this->pages;$i++) if($i == $this->page) echo '<span>'.$i.'</span>'; else echo "<a onclick=\"javascript: document.adminForm.page.value=$i; submitform();return false;\" title=\"$i\" href=\"#\">$i</a>";?>
						
						
					</div>
				</div>
				<div class="button2-left">
					<div class="next">
						<?php if($this->page < $this->pages ):?><a onclick="javascript: document.adminForm.page.value=<?php echo $this->page+1;?>; submitform();return false;" title="Следующая" href="#">Следующая</a>
						<?php else:?>
						<span>Следующая</span>
						<?php endif;?>
					</div>
				</div>
				<div class="button2-left">
					<div class="end">
					<?php if($this->page < $this->pages ):?><a onclick="javascript: document.adminForm.page.value=<?php echo $this->pages;?>; submitform();return false;" title="Следующая" href="#">Последняя</a>
						<?php else:?>
						<span>Последняя</span>
						<?php endif;?>
						
					</div>
				</div>
				<div class="limit">Страница <?php echo $this->page;?> из <?php echo $this->pages;?></div>
			
			</div>
			</td>
		</tr>
	</tfoot>
	<?php
	$k = 0;
	for ($i=0, $n=count( $this->items ); $i < $n; $i++)	{
		$row = &$this->items[$i];
		$checked 	= JHTML::_('grid.id',   $i, $row->id );
		$link 		= JRoute::_( 'index.php?option=com_shop&view=new_good&cid='. $row->id.'&pager='.$this->page.'&cat='.$this->cat_id );
		?>
		<tr class="<?php echo "row$k"; ?>">
			<td align="center">
				<?php echo $row->id; ?>
			</td>
			<td align="center">
				<?php echo $checked; ?>
			</td>
			<td>
				<?php if($row->main_img != '') echo '<img src="'.(JURI::root( true )).'/components/com_shop/images/small/'.$row->main_img.'" /><br/>'?>
			</td>
			<td>
				<?php echo $row->articul; ?>
			</td>
			<td>
				<a href="<?php echo $link; ?>"><?php echo htmlspecialchars($row->name); ?></a>
			</td>
			
			<td>
				<?php echo $row->cat_id; ?>
			</td>
			<td align="center">
				<?php if($row->published == 1) echo '<span style="color:green;font-size:12px;font-weight:bold;">Да</span>'; else echo '<span style="color:red;font-size:12px;font-weight:bold;">Нет</span>'?>
			</td>
			
		</tr>
		<?php
		$k = 1 - $k;
	}
	?>
	</table>
	
</div>

<input type="hidden" name="pager" value="<?php echo $this->page?>" />
<input type="hidden" name="cat" value="<?php echo $this->cat_id?>" />
<input type="hidden" name="page" value="" />
<input type="hidden" name="option" value="com_shop" />
<input type="hidden" name="view" value="goods"/>
<input type="hidden" name="task" value="" />
<input type="hidden" name="boxchecked" value="0" />

</form>
